<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;

// +----------------------------------------------------------------------
// | Date:2016年12月14日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class SlideController extends CommonController{
    
    protected $status;
    public function _initialize() {
        parent::_initialize();
        $this->model = M("Slide");
        $this->status = ['1'=>'显示','0'=>'隐藏'];
        $this->type = ['1'=>'图片','2'=>'视频'];
    }
    
    public function index(){
        $where['status'] = ['egt',0];
        $list = $this->lists($this->model,$where,$order='status desc,listorder desc');
        $this->assign('list',$list);
        $this->assign('status',$this->status);
        $this->display();
    }
    

    public function uploadFile(){
        $upload = new \Think\Upload();// 实例化上传类   
        $upload->maxSize   = 999999999 ;// 设置附件上传大小    
        $upload->exts      = array('mp4');// 设置附件上传类型   
        $upload->savePath  = 'video_slide/'; // 设置附件上传目录    // 上传文件     
        $upload->replace   = true;
        $upload->subName   = array('date','Ymd');
        $info   =   $upload->uploadOne($_FILES['file']);    
        if(!$info) {// 上传错误提示错误信息    
            $this->ajaxReturn(['status'=>0,'info'=>$upload->getError()]);    
        }else{// 上传成功        
            $data['status'] = 1;
            $data['path'] = $info['savepath'].$info['savename'];
            $this->ajaxReturn($data);    
        }  
    }
    
    
}